package org.jiuling.minio.config;

import org.jiuling.local.tools.verify.Assertions;

/**
 * MINIO配置
 * @author 紫灵
 * @date 2022年07月15日 14时45分40秒
 */
public class MinioConfig {

   /** 端点 */
    private String endpoint;
   /** 认证key */
    private String accessKey;
   /** 秘钥 */
    private String secretKey;

    public String getEndpoint() {
        return endpoint;
    }

    public void setEndpoint(String endpoint) {
        this.endpoint = endpoint;
    }

    public String getAccessKey() {
        return accessKey;
    }

    public void setAccessKey(String accessKey) {
        this.accessKey = accessKey;
    }

    public String getSecretKey() {
        return secretKey;
    }

    public void setSecretKey(String secretKey) {
        this.secretKey = secretKey;
    }

    public static class Builder{

        private final MinioConfig minioConfig;

        public Builder() {
            this.minioConfig = new MinioConfig();
        }

        /**
         * 添加端点
         * @param endpoint 端点
         * @return 当前对象
         */
        public Builder addEndpoint(String endpoint){
            minioConfig.endpoint = endpoint;
            return this;
        }

        /**
         * 添加认证key
         * @param accessKey 认证key
         * @return 当前对象
         */
        public Builder addAccessKey(String accessKey){
            minioConfig.accessKey = accessKey;
            return this;
        }

        /**
         * 添加秘钥
         * @param secretKey 秘钥
         * @return 当前对象
         */
        public Builder addSecretKey(String secretKey){
            minioConfig.secretKey = secretKey;
            return this;
        }

        /**
         * 构造Minio配置
         * @return Minio配置
         */
        public MinioConfig builder() {
            Assertions.stringIsNotBlank("端点不能为空",minioConfig.endpoint);
            Assertions.stringIsNotBlank("认证key不能为空",minioConfig.accessKey);
            Assertions.stringIsNotBlank("秘钥不能为空",minioConfig.secretKey);
            return minioConfig;
        }

    }
}
